package com.lagou.server;

import com.lagou.model.Student;
import com.lagou.model.StudentMessage;
import com.lagou.model.User;

import java.util.ArrayList;

/**
 * 编程实现数据的存取
 */
public class ServerDao {
     private StudentModule studentModule;

    public ServerDao(StudentModule studentModule) {
        this.studentModule = studentModule;
    }

    /**
     * 编程实现管理员账号和密码的校验并将结果返回出去
     * @param user
     * @return
     */
    public boolean serverManagerCheck(User user) {
        if ("admin".equals(user.getUserName()) && "123456".equals(user.getPassword())) {
            return true;
        }
        return false;
    }
    public boolean serverStudentCheck(StudentMessage strum, ArrayList<Student> arrayList) {
        Student S= studentModule.findOF(strum.getS(),arrayList);
        if (S!=null){
            if (S.getId()==strum.getS().getId()&&S.getPassword().equals(strum.getS().getPassword())){
                return true;
            }else {
                return false;
            }
        }
        else {
            return  false;
        }


    }

}
